// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.network;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.util.HashMap;
import se.krka.kahlua.vm.KahluaTable;

public class DBSchema {
    private HashMap<String, HashMap<String, String>> schema = new HashMap();
    private KahluaTable fullTable;

    public DBSchema(Connection conn) {
        try {
            DatabaseMetaData databaseMetaData = conn.getMetaData();
            String[] string0 = new String[]{"TABLE"};
            ResultSet resultSet0 = databaseMetaData.getTables(null, null, null, string0);

            while (resultSet0.next()) {
                String string1 = resultSet0.getString(3);
                if (!string1.startsWith("SQLITE_")) {
                    ResultSet resultSet1 = databaseMetaData.getColumns(null, null, string1, null);
                    HashMap hashMap = new HashMap();

                    while (resultSet1.next()) {
                        String string2 = resultSet1.getString(4);
                        if (!string2.equals("world")
                            && !string2.equals("moderator")
                            && !string2.equals("admin")
                            && !string2.equals("password")
                            && !string2.equals("encryptedPwd")
                            && !string2.equals("pwdEncryptType")
                            && !string2.equals("transactionID")) {
                            hashMap.put(string2, resultSet1.getString(6));
                        }
                    }

                    this.schema.put(string1, hashMap);
                }
            }
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    public KahluaTable getFullTable() {
        return this.fullTable;
    }

    public void setFullTable(KahluaTable kahluaTable) {
        this.fullTable = kahluaTable;
    }

    public HashMap<String, HashMap<String, String>> getSchema() {
        return this.schema;
    }
}
